<?php
namespace app\console\controller\goods;

use app\model\Goods;
use DateTime;

class GoodsAPISchemes
{
    private $dateTime;

    public function __construct()
    {
        $this->dateTime = $dateTime = app('DateTime');;
    }

    public function goods(Goods $goods)
    {
        $result = [
            'id' => $goods->id,
            'name' => $goods->name,
            'supplier_id' => $goods->supplier_id,
            'number' => $goods->number,
            'type' => $goods->type,
            // TODO $goods->tags是否数组
            'tags' => $goods->tags,
            'is_packaged' => $goods->is_packaged,
            'material' => $goods->material,
            'suitable_people' => $goods->suitable_people,
            'has_storage' => $goods->has_storage,
            'customizable' => $goods->customizable,
            'model' => $goods->model,
            'fill' => $goods->fill,
            // TODO $goods->other_features是否数组
            'other_features' => $goods->other_features,
            'finish_meterial' => $goods->finish_meterial,
            'style' => $goods->style,
            'dispatch_place_province' => $goods->dispatch_place_province,
            'dispatch_place_city' => $goods->dispatch_place_city,
            'dispatch_place_district' => $goods->dispatch_place_district,
            'dispatch_place_address' => $goods->dispatch_place_address,
            // TODO $goods->skus是否数组
            'skus' => $goods->skus,
            'machining_scheme_id' => $goods->machining_scheme_id,
            // TODO $goods->attrs是否数组
            'attrs' => $goods->attrs,
            'invoice' => $goods->invoice,
            'guarantee' => $goods->guarantee,
            'return_promise' => $goods->return_promise,
            'brand' => $goods->brand,
            'detail' => $goods->detail,
            'remark' => $goods->remark,
            // TODO $goods->pictures是否数组
            'pictures' => $goods->pictures,
            // TODO $goods->images是否数组
            'images' => $goods->images,
            'status' => $goods->status,
            'create_time' => $goods->create_time,
            'update_time' => $goods->update_time,
            'format_create_time' => $this->dateTime->timestamp2date($goods->create_time),
            'format_update_time' => $this->dateTime->timestamp2date($goods->update_time),
        ];

        /**
         * TODO 供应商信息
         */
        if (false)
        {
            $result['supplier'] = [
                'id' => 0,
                'name' => '',
            ];
        }

        return $result;
    }
}